import Http, {HttpParamsProps, ReqProps} from "@/common/http";
import {BaseEntity} from "@/common/httptypes";
import {SysMenuTree} from "@/api/sys-menu";
import {SelectDataArray} from "@/components/ant-ext/HStaticSelect";


export type SysRoleEntity = {
    roleCode: string
    roleName: string
    orgCode: string
    orgCodePath: string
    orgNamePath: string
    adminNumber: number
    stat: boolean
} & BaseEntity


class SysRole {
    RowKey = "roleCode"
    EDIT = "RoleEdit"
    ADD = "RoleAdd"
    DEL = "RoleDel"
    ROLE_MENU = "roleMenu"
    MAPPING = {RoleEdit: "编辑角色", RoleAdd: "新增角色"}
    ROLE_MENU_MAPPING = {roleMenu: "分配权限"}


    selectTablePage(props: HttpParamsProps): Promise<Response> {
        return Http.get("/api/role/page", props)
    }

    selectById(props: ReqProps<SysRoleEntity>) {
        Http.doGet("/api/role/find", props)
    }

    selectList(props: ReqProps<SelectDataArray>) {
        Http.doGet("/api/role/list", props)
    }

    selectRoleMenu(props: ReqProps<{ selected: string[], list: SysMenuTree[] }>) {
        Http.doGet("/api/role/menus", props)
    }

    doEdit(props: ReqProps<void>) {
        Http.doPost("/api/role/edit", props)
    }

    doEditRoleMenu(props: ReqProps<void>) {
        Http.doPost("/api/role/menu/edit", props)
    }

    delete(props: ReqProps<void>) {
        Http.doPost("/api/role/delete", props)
    }

}

// eslint-disable-next-line import/no-anonymous-default-export
export default new SysRole()